<?php

namespace App\Http\Controllers\Home\Tv;
use App\Model\Tv;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;

class Tvcontroller extends Controller
{
    //
    public function tv(Request $request){
        $pindao_id= $request->input('pindao')? $request->input('pindao') : '1';
        $type= $request->input('type')? $request->input('type') : 'gaoqing';
        $pindao_info = Tv::find($pindao_id);

        $pindao1_list = $this->getPinDao(1);
        $pindao2_list = $this->getPinDao(2);
        $pindao3_list = $this->getPinDao(3);
        $pindao4_list = $this->getPinDao(4);
        $pindao5_list = $this->getPinDao(5);
        return view('home.tv.tv',[
            'pindao_info' => $pindao_info,
            'pindao1_list' => $pindao1_list,
            'pindao2_list' => $pindao2_list,
            'pindao3_list' => $pindao3_list,
            'pindao4_list' => $pindao4_list,
            'pindao5_list' => $pindao5_list,
            'type' => $type,
        ]);
    }
    public function getPinDao($type=null){
        if(!$type){
            $list = Tv::get();
        }else{
            $list = Tv::where(array('type' => $type))->get();
        }
        return $list;
    }
}
